//
//  HXChangePwdViewController.m
//  KD
//
//  Created by ifly on 16/3/16.
//  Copyright © 2016年 Whx. All rights reserved.
//
 
#import "HXChangePwdViewController.h"

@interface HXChangePwdViewController ()
@property (weak, nonatomic) IBOutlet UITextField *oldPwdTextField;
@property (weak, nonatomic) IBOutlet UITextField *newsPwdTextField;

@end

@implementation HXChangePwdViewController


- (IBAction)okBtnClick:(id)sender {
    if ([GlobalUtil isNilValue:self.oldPwdTextField.text]) {
        [SVProgressHUD showErrorWithStatus:@"请输入原密码!"];
        return;
    }
    if ([GlobalUtil isNilValue:self.newsPwdTextField.text]) {
        [SVProgressHUD showErrorWithStatus:@"请输入新密码!"];
        return;
    }
    [SVProgressHUD showWithStatus:@"正在修改"];
    [NetworkAPI changePwdtWithUserId:[UserDefaultHandler getUserDetault:kID]
                                                    OldPwd:self.oldPwdTextField.text
                                                    NewPassWord:self.newsPwdTextField.text
                    success:^(HXBaseModel *result) {
                        if ([result.code isEqualToString:@"200"]) {
                            [SVProgressHUD showSuccessWithStatus:@"修改成功"];
                        }else if ([result.code isEqualToString:@"400"]){
                            [SVProgressHUD showErrorWithStatus:@"原密码错误"];
                        }else{
                            [SVProgressHUD showErrorWithStatus:@"网络错误"];
                        }
                         } failure:^(NSError *err) {
                              [SVProgressHUD showErrorWithStatus:@"网络错误"];
                         }];
}

@end
